<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>CorkBoard It!</title>
</head>

<body>

<?php
	session_start();
	
	$host="localhost";
	$username="root";
	$password="";
	$database="cs4400_group17";

	mysql_connect($host,$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	
	$username = $_SESSION['userName'];
	$useremail = $_SESSION['userEmail'];
	
	$corkboardEmail = $_POST['corkboardEmail'];
	$corkboardTitle = $_POST['corkboardTitle'];
	$corkboardCategoryName = $_POST['corkboardCategoryName'];
	$corkboardLastUpdate = $_POST['corkboardLastUpdate'];
?>
<div id="masthead">
	<h1>CorkBoard<span style="color:red;">It</span></h1>
	<p style="color:orange;margin-top:-10px"><b>Explore. Share. Inspire.</b></p>
</div>

<div id="container">
	<?php
		$sql = "SELECT Password From privatecb WHERE Email='$corkboardEmail' AND Title ='$corkboardTitle'";
		$result = mysql_query($sql);
		$row = mysql_fetch_array($result);
		$password = $row[0];
		
		if($useremail != $corkboardEmail && $password){?>
			<h1>This corkboard is private.<h1>
			<h2>Please enter the password: <h2>
			<form name='myform' action='CheckPrivatePassword.php' method='post'>
				<input type="hidden" name="corkboardEmail" value="<?php echo $corkboardEmail;?>">
				<input type="hidden" name="corkboardTitle" value="<?php echo $corkboardTitle;?>">
				<input type="hidden" name="corkboardCategoryName" value="<?php echo $corkboardCategoryName;?>">
				<input type="hidden" name="corkboardLastUpdate" value="<?php echo $corkboardLastUpdate;?>">
				<input type="hidden" name="realPassword" value="<?php echo $password;?>">
				<input type='text' name='password'>
				<input type='submit' value='Enter'>
			</form>
		<?php
		}else{?>
			<form name='myform' action='ViewCorkboard.php' method='post'>
				<input type="hidden" name="corkboardEmail" value="<?php echo $corkboardEmail;?>">
				<input type="hidden" name="corkboardTitle" value="<?php echo $corkboardTitle;?>">
				<input type="hidden" name="corkboardCategoryName" value="<?php echo $corkboardCategoryName;?>">
				<input type="hidden" name="corkboardLastUpdate" value="<?php echo $corkboardLastUpdate;?>">
				<script language="JavaScript">document.myform.submit();</script>		
			</form>
		<?php
		}
	?>
</div>

</body>

</html>